﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Micro.Core.FrameWork.ORM.EntityFrameworkCore
{
    public interface IRepository<TEntity> where TEntity : BaseModel
    {
        Task AddAsync(TEntity obj);
        void Add(TEntity obj);
        Task<TEntity> GetAsync(Guid id);
        TEntity Get(Guid id);
        Task<TEntity> GetNoTrackingAsync(Guid id);
        /// <summary>
        /// 获取列表动态条件
        /// </summary>
        /// <param name="prExpression"></param>
        /// <returns></returns>
        IQueryable<TEntity> Get(Expression<Func<TEntity, bool>> prExpression);
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        IEnumerable<TEntity> Get();

        /// <summary>
        /// 根据id软删除
        /// </summary>
        /// <param name="obj"></param>
        Task RemoveAsync(TEntity obj);
        /// <summary>
        /// 根据id物理删除
        /// </summary>
        /// <param name="obj"></param>
        Task RemoveHardAsync(TEntity obj);
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        Task<int> SaveChangesAsync();
        int SaveChanges();
    }
}
